//
//  XMLSubjectParser.m
//  LanguagesTeach
//
//  Created by Niel Santos on 2/9/13.
//  Copyright 2013 __MyCompanyName__. All rights reserved.
//

#import "XMLSubjectParser.h"
#import "Entry.h"

@implementation XMLSubjectParser

@synthesize entries;

- (void)parser:(NSXMLParser *)parser 
didStartElement:(NSString *)elementName
  namespaceURI:(NSString *)namespaceURI
 qualifiedName:(NSString *)qualifiedName
	attributes:(NSDictionary *)attributeDict{
	
	Entry *entry;
	
	if([elementName isEqualToString:@"subject"]) {
		entries = [[NSMutableArray alloc] init];
	}else if([elementName isEqualToString:@"entry"]) {
		entry = [[Entry alloc] init];
		entry.imagePath = [attributeDict objectForKey:@"img"];
		entry.imageDescription = [attributeDict objectForKey:@"text"];
		entry.soundPath = [attributeDict objectForKey:@"sound"];
		[entries addObject: entry];
		[entry release];
	}
}


- (void)dealloc {
	[entries release];
    [super dealloc];
}

@end